package com.pk.springbootsy1.dto;

import cn.hutool.core.bean.BeanUtil;
import com.pk.springbootsy1.entity.TUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@Schema(name = "TUserDto", description = "设备信息")
public class TUserDto {

    @Schema(description = "用户id")
    private Integer id;
    @Schema(description = "用户登录名")
    private String loginName;
    @Schema(description = "用户真实姓名")
    private String realName;
    @Schema(description = "用户密码")
    private String password;
    @Schema(description = "用户电话")
    private String tel;
    @Schema(description = "用户邮箱")
    private String email;
    @Schema(description = "用户类型")
    private Integer type;
    @Schema(description = "用户最后登录时间")
    private Date lastLoginTime;

    public static List<TUserDto> convert(List<TUser> users) {
        List<TUserDto> userDtos = new ArrayList<>();
        users.stream().forEach(s -> {
            TUserDto dto = new TUserDto();
                    BeanUtil.copyProperties(s, dto);
                    userDtos.add(dto);
                }
        );
        return userDtos;
    }
    public static TUserDto convert(TUser user) {
        TUserDto dto = new TUserDto();
        BeanUtil.copyProperties(user, dto);
        return dto;
    }
}